﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
using System.Data.SqlClient;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Data;
using System.Collections;

namespace CDTM.Modules.TraCuuDiem.Components
{
    public partial class DiemHocPhan
    {
        public static List<DiemHocPhan> Clean(List<DiemHocPhan> list)
        {
            List<DiemHocPhan> newList = new List<DiemHocPhan>();

            var cleanList = from item in list where item.MaSV != "" select item;

            foreach (DiemHocPhan obj in cleanList)
            {
                newList.Add(obj);
            }

            return newList;
        }

        //---------------------------------------------------------------------------------------------

        public static int DeleteAll()
        {
            return DeleteDynamic("1=1");
        }

        //---------------------------------------------------------------------------------------------

        public static int DeleteAllBy(Guid moduleID, int heDaoTaoID, int namHocID, int hocKyID, int hocPhanID)
        {
            string where = string.Format("ModuleID = '{{{0}}}' AND HeDaoTaoID = {1} AND NamHocID= {2} AND HocKyID = {3} AND HocPhanID = {4}",
                moduleID, heDaoTaoID, namHocID, hocKyID, hocPhanID);

            return DiemHocPhan.DeleteDynamic(where);
        }

        //---------------------------------------------------------------------------------------------

        public static int DeleteAllBy(Guid moduleID, int heDaoTaoID, int namHocID, int hocKyID, int hocPhanID, string tenLop)
        {
            string where = string.Format("ModuleID = '{{{0}}}' AND HeDaoTaoID = {1} AND NamHocID= {2} AND HocKyID = {3} AND HocPhanID = {4} AND Lop = '{5}'",
                moduleID, heDaoTaoID, namHocID, hocKyID, hocPhanID, tenLop);

            return DiemHocPhan.DeleteDynamic(where);
        }
        
    }
}
